using System.Collections.Generic;

namespace OracleInternal.SqlAndPlsqlParser
{
	internal class OracleSqlEarley : Earley
	{
		public OracleSqlEarley(OracleSqlEarleyParserGrammarDefinition grammar)
			: base(grammar)
		{
		}

		public string TestParse(string s)
		{
			List<LexerToken> src;
			using (new PerformanceTimer("Lexing"))
			{
				src = LexerToken.Parse(s);
			}
			try
			{
				using (new PerformanceTimer("Parsing"))
				{
					ParseNode parseNode = Parse(s, src);
					if (parseNode != null)
					{
						return parseNode.ToString(base.EarleyGrammar);
					}
					return "Parse failed";
				}
			}
			catch (ParserException ex)
			{
				return ex.ToString();
			}
		}
	}
}
